package com.apes.scm.masterdata.party.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.party.model.Corporate;
import com.apes.scm.masterdata.party.model.Party;
import org.springframework.data.jpa.repository.Query;

/**
 * @author xul
 * @create 2018-02-06 16:47
 */
public interface CorporateRepository extends CustomRepository<Corporate, Long> {
    Corporate findByParty(Party party);

    @Query(value = "  SELECT C.* FROM MAS_CORPORATE C WHERE C.PARTY_ID =  (SELECT B.PARTY_ID  FROM MAS_PARTY_ROLE B WHERE B.id=:id) ", nativeQuery = true)
    Corporate findByPartyRole(String id);
}
